package bist.believeinstep.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import bist.believeinstep.domain.Image;
import bist.believeinstep.util.Constant.ImageType;

public class ImageMapper implements RowMapper<Image>{
	public Image mapRow(ResultSet rs, int rowNum) throws SQLException{
		
		Image image = new Image();
		
		image.setId(rs.getInt("id"));
		image.setName(rs.getString("name"));
		image.setLink(rs.getString("link"));
		image.setImage(rs.getString("image"));
		image.setTag(rs.getString("tag"));
		
		String type = rs.getString("type");
		image.setType(ImageType.create(type));
		
		image.setCreated(rs.getTimestamp("created_date"));
		image.setModified(rs.getTimestamp("modified_date"));
		image.setCreatedBy(rs.getString("created_by"));
		image.setModifiedBy(rs.getString("modified_by"));
		
		return image;
	}
}
